package string;

/**
 * java中如何用代码实现将一段字符串每隔5个字符就加上“/n”
 * @author Administrator
 *
 */
public class Example4 {
	public static void main(String args[]) {
		String str = "我很想将一段字符串从第一个字符开始往后数,每隔五个就在后面加上换行符，请各位java高手帮忙，谢谢";
		StringBuffer s = new StringBuffer(str);
		for (int index = 0; index < s.length(); index++) {
			if (index % 6 == 0) {
				s.insert(index, "\n");
			}
		}
		System.out.println("After insert:" + s.toString());
	}

}